package com.zxx.pattern.compositePattern.composite2;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zxx on 2021/5/20
 */
public class Composite2 implements Component2 {
    private List<Component2> list = new ArrayList<>();

    @Override
    public void doSomething() {
        for (Component2 component : list) {
            component.doSomething();
        }
    }

    @Override
    public void add(Component2 component) {
        list.add(component);
    }

    @Override
    public void remove(Component2 component) {
        list.remove(component);
    }

    @Override
    public List<Component2> getAll() {
        return this.list;
    }
}
